﻿Imports System.Data.OleDb

Public Class DataProvider
    Shared conn As OleDbConnection
    Public Shared Function OpenConnecttion()
        Dim strconnect As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=QuanLyThuVien.mdb"
        conn = New OleDbConnection(strconnect)
        conn.Open()
        Return conn
    End Function

    Public Shared Sub CloseConnect()
        conn.Close()
    End Sub

    Public Shared Function ExecInsert(ByVal strsql As String) As Integer
        Dim command As New OleDbCommand(strsql, conn)
        Return command.ExecuteNonQuery()
    End Function

    Public Shared Function ExecDelete(ByVal strsql As String) As Integer
        Dim command As New OleDbCommand(strsql, conn)
        Return command.ExecuteNonQuery()
    End Function

    Public Shared Function ExecSelect(ByVal strsql As String) As OleDbDataReader
        Dim command As New OleDbCommand(strsql, conn)
        Dim reader As OleDbDataReader = command.ExecuteReader()
        Return reader
    End Function
End Class
